import components from './components'

import crud from './mixins/crud'
import dict from './utils/util.dicts'
import height from './utils/util.height'
import columnResolve from './utils/util.column.resolve'
import commonOptions from './utils/util.options.common'
import { isFunction, isEmpty } from 'lodash'

const util = {
  dict,
  height,
  columnResolve,
  commonOptions
}

const install = (Vue, options) => {
  for (let key in components) {
    Vue.component(components[key].name, components[key])
  }
  const { getRemoteDictFunc, commonOption } = options || {}
  if (!isEmpty(getRemoteDictFunc) && isFunction(getRemoteDictFunc)) {
    console.log(122)
    util.dict.getRemoteDictFunc = options.getRemoteDictFunc
  }
  if (!isEmpty(commonOption) && isFunction(commonOption)) {
    commonOptions.create = options.commonOption
  }
}
// if (typeof window !== 'undefined' && window.Vue) {
//   install(window.Vue)
// }
export default {
  install,
  util,
  crud
}
